package com.information.manage.basic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.information.manage.basic.model.entity.DepartmentDO;
import com.information.manage.basic.model.vo.DepartmentListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2021-12-27
 */
@Mapper
public interface DepartmentMapper extends BaseMapper<DepartmentDO> {

    /**
     * 根据父id查询最大的排序层级
     * @param parentId 父id
     * @param typeCollection 部门类型集
     * @return 层级
     */
    Integer queryMaxOrderByParentId(@Param("parentId") Integer parentId, @Param("typeCollection") Long typeCollection);

    /**
     * 根据父id查询子部门
     * @param id 部门id
     * @return
     */
    List<DepartmentListVO> queryDepartmentListById(Integer id);

    /**
     * 根据名称模糊查询部门
     * @param departmentName 部门名称
     * @param typeCollection 部门类型集
     * @return
     */
    List<DepartmentDO> queryDepartmentListByName(@Param("departmentName") String departmentName, @Param("typeCollection") Long typeCollection);

    /**
     * 查询某个部门下的层级大于某个值的子部门
     * @param typeCollection 部门类型集
     * @param parentId 父id
     * @param sequence 层级
     * @return
     */
    List<DepartmentDO> queryDepartmentListByPidAndSequence(@Param("typeCollection") Long typeCollection, @Param("parentId") Integer parentId, @Param("sequence") Integer sequence);

}
